//Copyright (c) 2012 Olof Wallentin  <olov.wallentin@gmail.com>

//This software is provided 'as-is', without any express or implied
//warranty. In no event will the authors be held liable for any damages
//arising from the use of this software.

//Permission is granted to anyone to use this software for any purpose,
//including commercial applications, and to alter it and redistribute it
//freely, subject to the following restrictions:

   //1. The origin of this software must not be misrepresented; you must not
   //claim that you wrote the original software. If you use this software
   //in a product, an acknowledgment in the product documentation would be
   //appreciated but is not required.

   //2. Altered source versions must be plainly marked as such, and must not be
   //misrepresented as being the original software.

   //3. This notice may not be removed or altered from any source
   //distribution.
#pragma once
#include <string>
#include <sstream>

namespace ne{
class Convert {
public:
	static const std::string BoolToString(bool p_value);
	template <typename T> const static std::string NumberToString(const T);			// converts any given value to a std::string
	template <typename T> static T StringToNumber(const std::string&);					// converts a std::string to any valid number
	static bool StringToBool(const std::string&);	// converts a string into a bool
	static btQuaternion ToBullet(const Ogre::Quaternion& q);
	static btVector3 ToBullet(const Ogre::Vector3& v);
	static Ogre::Quaternion ToOgre(const btQuaternion& q);
	static Ogre::Vector3 ToOgre(const btVector3& v);
};

template <typename T> const std::string Convert::NumberToString(const T p_line) {
	std::stringstream stream;
	stream << p_line;
	return stream.str();
}


template <typename T> T Convert::StringToNumber(const std::string& p_line) {
	std::stringstream stream(p_line);
	T result;
	return stream >> result ? result : 0;
}
}